<!DOCTYPE html>
<?php
include 'product.php';
session_start();
$sum=0;
if(!empty($_SESSION['cart'])){
	$orde=$_SESSION['cart'];
	$sum=array_sum(array_column($order,"num"));
}
?>
<html>
	<head>
		<meta charset="utf-8">
		<link rel="stylesheet" type="text/css" href="css/style.css" />
		<title>PHP购物车</title>
	</head>
	<body>
		<div>
			<table>
				<tr>
					<th>商品名</th>
					<th>售价</th>
					<th>购物车</th>
				</tr>
				<?php foreach ($products as $key => $value):?>
				<tr>
					<td><?php echo $value['name'];?></td>
					<td>￥<?php echo $value['price'];?></td>
					<td><a class="btn" href="addCar.php?upd=add$id=<?php echo $value['id'];?>
					&name=<?php echo $value['name'];?>
					&price=<?php echo $value['price'];?>+</a></td>
				</tr>
				<?php endforeach;?>
			</table>
		</div>
		<a href="addCart.php?upd=cart">我的购物车</a>
		<span><?php echo $sum;?></span>
	</body>
</html>